home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 62 / Quick PC 62.iso / I386 / IIS5_01.CAB / IIS_JSBRWSET.ASP1 < prev    next >
Encoding:
Text File  |  1999-06-03  |  3.7 KB  |  163 lines

  1. <%@ LANGUAGE = VBScript %>
  2. <% 'Option Explicit %>
  3. <!-- #include file="../directives.inc" -->
  4.  
  5. <!--#include file="jsbrowser.str"-->
  6.  
  7. <% 
  8. 'Call this page with a query string of ?sname=machinename
  9. 'example: http://larad01/iis/iicnct.asp?sname=larad01
  10.  
  11. 'On Error Resume Next 
  12.  
  13. Dim path, sname, scripttimeout, FileSystem, quote, errd, currentADsObj, lastobj
  14. Dim newid, topid, firstid, currentid, numNewItems
  15.  
  16.  
  17. 'This script can take a _long_ time to execute,
  18. 'as we may be dealing with thousands of items
  19. 'to add to our JScript object.
  20. 'save our current script timeout value & set to a much longer value...
  21.  
  22. scripttimeout = Server.ScriptTimeOut
  23. Server.ScriptTimeOut = 2000
  24.  
  25. Set FileSystem=CreateObject("Scripting.FileSystemObject")
  26.  
  27. path=Request.QueryString("fspath")
  28.  
  29. quote=chr(34)
  30. errd=False
  31. lastobj = ""
  32. %>
  33.  
  34. <HTML>
  35. <HEAD>
  36. <SCRIPT LANGUAGE="JavaScript">
  37.  
  38. var theList=parent.head.cachedList;
  39. var listFuncs = new parent.head.listFuncs();
  40.  
  41. <% 
  42.  
  43. if errd=0 then     
  44.  
  45.     newid=Request("newid")
  46.     
  47.     firstid=newid
  48.     if firstid="" then
  49.         firstid=0
  50.     end if 
  51.     
  52.     currentid=Request("item")
  53.     if currentid="" then
  54.         currentid=firstid
  55.         newid=newid + 1
  56.     end if 
  57.     
  58.     numNewItems=0    
  59.     Response.write "//" & path
  60.     Response.write "//" & currentid
  61.  
  62.     addDirs path, currentid    
  63.     
  64.     Server.ScriptTimeOut = scripttimeout
  65. end if
  66.  
  67. Sub addDirs(path, parentid)
  68.     Dim thisid, thisname, thisstate, thisadspath, i, f
  69.     if path <> "" then 
  70.         if FileSystem.FolderExists(path) then    
  71.              Set f=FileSystem.GetFolder(path)
  72.              For Each i In f.SubFolders
  73.                  thisid=newid
  74.                  SetJscriptObj i, i.Name,parentid
  75.                   numNewItems=numNewItems + 1     
  76.              Next
  77.         end if
  78.     end if
  79. End Sub
  80.  
  81. Sub SetJscriptObj(path, caption, parentid)
  82.      %>
  83.     theList[<%= newid %>]=new parent.head.listObj(<%= newid %>,"<%= Replace(path,"\","\\") %>","<%= caption %>",<%= parentid %>);
  84.     <% 
  85.     newid=newid + 1
  86. End Sub
  87.  
  88.  
  89. ' we need to insert the whole group into the correct place In the array.
  90. ' since we Set the first entry (machine) to the exisitng place In the array,
  91. ' the Next level In the hierarchy (vservers) will be pointing to the correct
  92. ' parent ids. However, the following level (vdirs, and below) will be pointing
  93. ' to the parent ids as they existed at the bottom of the array, before the
  94. ' move, and will need to be adjusted.
  95. %>
  96.  
  97. <% if errd=0 then %>
  98.  
  99.     var item=<%= firstid %>;
  100.     currentid=<%= currentid %>;
  101.     if (currentid !=item){
  102.  
  103.         x=currentid + 1;
  104.     
  105.         //correct the id on the "new" objects
  106.         for (var i=item; i < theList.length; i++) {
  107.                 theList[i].id=x;            
  108.                 if (theList[i].parentid !=currentid){
  109.                     theList[i].parentid=theList[i].parentid - (item - (currentid + 1));
  110.                 }        
  111.                 x++;
  112.         }
  113.     
  114.         //move the following records "down" the array
  115.         for (var i=currentid + 1; i < item;i++){
  116.  
  117.             theList[i].id=theList[i].id + <%= numNewItems %>;
  118.             if (theList[i].parentid >currentid){
  119.                     theList[i].parentid=theList[i].parentid + <%= numNewItems %>;
  120.             }    
  121.         }
  122.     
  123.  
  124.     }
  125.  
  126.  
  127.     //and re-sort.
  128.     theList[0].sortList();
  129.     theList[0].markTerms();
  130.  
  131.  
  132.     if (theList.length==1){
  133.         listFuncs.selIndex=0;
  134.         theList[0].selected=true;
  135.     }
  136.     else{
  137.         theList[listFuncs.selIndex].selected=false;
  138.         listFuncs.selIndex=<%= currentid %>;
  139.         theList[<%= currentid %>].selected=true;
  140.     }
  141.  
  142.     // Force a refresh
  143.     listFuncs.loadList();
  144.  
  145. <% else %>
  146.     alert("<%= L_CNCTERR_TEXT %> (<%= err %>)");
  147. <% end if %>
  148.  
  149.  
  150. </SCRIPT>
  151.  
  152. <% if err <> 0 then %>
  153. <% Response.write "err: " & err.description %><BR>
  154. <% Response.write "currentcontainer: " & currentADsObj.ADsPath %><BR>
  155. <% Response.write "                  " & currentADsObj.KeyType %><BR>
  156. <% Response.write "Err Container:" & lastobj %><BR>
  157. <% end if %>
  158.  
  159.  
  160. </HEAD>
  161. <BODY>
  162. </BODY>
  163. </HTML>